﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CinemaBookingWebsite
{
    public partial class Movie : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strId = Request.QueryString["MovieID"];
                int id;
                if (int.TryParse(strId, out id))
                {
                    //CinemaWcf.ICinemaWcf cinemaWcf = new CinemaWcf.CinemaWcfClient();
                    CinemaWcf.ICinemaWcf cinemaWcf = new CinemaWcf.CinemaWcfClient();
                    var m = cinemaWcf.GetMovieById(id);
                    if (m != null)
                    {
                        lblMovie.Text = m.MovieTitle;
                        lblDesc.Text = m.MovieDescription;

                        lblPrice.Text = m.MoviePrice.ToString() + " kr.";
                        if (m.MoviePoster != null || m.MoviePoster != "")
                        {
                            imgMovie.ImageUrl = "Posters/" + m.MoviePoster + ".jpg";
                        }
                        if (m.MoviePoster == null || m.MoviePoster == "")
                        {
                            imgMovie.ImageUrl = "Posters/null.jpg";
                        }


                        RepeaterScreening.DataSource = cinemaWcf.GetCurrentScreeningByMovieID(id);
                        RepeaterScreening.DataBind();
                    }
                }



            }
        }

    }
}